<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class RecycleController extends Controller
{
    //找到回收站状态为2的订单
    public function index(Request $request)
    {
    	$name = '';
        if($request->has('name')){
            $name = $request->input('name');
        }
        $list = DB::select("select * from `receive_address` inner join `myorder` on `receive_address`.`id` = `myorder`.`reveive_address_id` where recycle=2 and myorder.id like '%{$name}%'");
        return view('myorder.recycle',['list'=>$list]);
    }
    //将回收站中的数据还原成订单
    public function destroy($id)
    {
        $row = DB::table('myorder')->where('id',$id)->update(['recycle'=>1]);
        if($row>0){
            return redirect('admin/recycle')->with('msg','订单'.$id.'还原成功');
        }
    }
}